import 'package:flutter/material.dart';
import 'package:navigate_demo/screens/args/detail_args.dart';

class DetailScreen extends StatelessWidget{
  final int productId;
  final String productName;
  
  const DetailScreen({
    super.key,
    required this.productId,
    required this.productName,
});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('$productName 详情'),
        leading: IconButton(
         onPressed: ()=>Navigator.pop(context), 
            icon: const Icon(Icons.arrow_back))
        ),
      body: Padding(
        padding: const EdgeInsets.all(20.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Card(
              elevation: 3,
              child: Padding(padding: const EdgeInsets.all(16),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      const Text('商品信息',
                        style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
                      const SizedBox(height: 15,),
                      _buildInfoRow('商品ID', productId.toString()),
                      _buildInfoRow('商品名称', productName),
                      _buildInfoRow('上架状态', '在售'),
                      _buildInfoRow('库存数量', '128'),
                    ],
                  ),
              ),
            ),
            const SizedBox(height: 30),
            const Text('商品描述',
              style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),),
            const SizedBox(height: 10),
            const Text(
              '这是一款高品质的商品，采用先进技术和优质材料制造，提供卓越的性能和用户体验。',
              style: TextStyle(fontSize: 16, height: 1.5),),
            const Spacer(),
            Center(
              child: ElevatedButton(
                onPressed: ()=>Navigator.pop(context),
                style: ElevatedButton.styleFrom(
                  backgroundColor: Colors.blue,
                  foregroundColor: Colors.white,
                  padding: const EdgeInsets.symmetric(horizontal: 40,vertical: 15),
                ),
                child: const Text("返回"),
              ),
            ),
            const SizedBox(height: 20,)
          ],
        ),
      ),
    
    );
  }

  Widget _buildInfoRow(String label,String value){
    return Padding(padding: const EdgeInsets.symmetric(vertical: 8.0),
    child: Row(
      children: [
        SizedBox(
          width: 100,
          child: Text(
            label,
            style: const TextStyle(color: Colors.grey),
          )),
          Text(
            value,style: const TextStyle(fontWeight: FontWeight.bold),
          ),

      ],
    ),);
  }

  
}